<template>
    <div class="quality-system">
        <el-button  @click="openPrintData" type="primary" style="position: fixed;top: 80px;right: 10px;padding: 6px 15px;z-index: 999;">查看</el-button>
        <!-- 主页 -->
        <el-tabs v-model="activeName" @tab-click="handleDialogClick">
                <el-tab-pane label="文件基本信息" name="1" :style="tableDialogHeightTabPane">
                    <!-- 基本信息列表-->
                    <h3 class="dialog-plate-title"><span>基本信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="150px"
                             :model="dialogList1">
                        <el-form-item label="文件名称">
                            <el-input v-model="dialogList1.fileName" :disabled="dialogTitle !=='添加'"></el-input>
                        </el-form-item>
                        <el-form-item label="文件编码">
                            <el-input v-model="dialogList1.fileCode" :disabled="dialogTitle !=='添加'"></el-input>
                        </el-form-item>
                        <el-form-item label="版本号">
                            <el-input v-model="dialogList1.versionCode" :disabled="dialogTitle !=='添加'"></el-input>
                        </el-form-item>
                        <el-form-item label="修订次数">
                            <el-input v-model="dialogList1.updateTimes" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="文件创建人">
                            <el-input v-model="dialogList1.fileWriterName " disabled></el-input>
                        </el-form-item>
                        <el-form-item label="创建日期">
                            <el-input v-model="dialogList1.createTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="最后修改日期">
                            <el-input v-model="dialogList1.lastUpdateTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="所属文件夹">
                            <el-input v-model="dialogList1.fileGs" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="文件发布人">
                            <el-input v-model="dialogList1.fileApproverName" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="文件是否发布">
                            <el-select v-model="dialogList1.isApproval" :disabled="dialogTitle ==='添加'">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="相关部门">
                            <el-select v-model="dialogList1.fileUseScope" :disabled="isFileUseScope" multiple
                                       placeholder="请选择">
                                <el-option
                                        v-for="item in departments"
                                        :key="item.id"
                                        :label="item.deptName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <div style="text-align: right;margin-top: 20px;padding-right: 20px;">
                        <div v-if="dialogTitle !=='添加'">
                            <el-button v-if="jurisdiction.fileRelease" @click="submitDialogData1"
                                       :disabled="!isDialogButton " type="primary">发布
                            </el-button>
                        </div>
                        <div v-else>
                            <el-button v-if="jurisdiction.addBaseInfo" @click="submitDialogData1"
                                       :disabled="!isDialogButton" type="primary">新增
                            </el-button>
                        </div>
                    </div>

                    <!-- 申请修改单记录-->
                    <h3 v-if="dialogTitle !=='添加'" class="dialog-plate-title"><span>记录</span></h3>
                    <el-tabs v-if="dialogTitle !=='添加'" v-model="activeTableName" @tab-click="handleRecordClick"
                             style="height: 500px; padding-right: 10px;">
                        <el-tab-pane label="申请修改记录" name="first">
                            <el-button v-if="jurisdiction.addEditApplyInfo" @click="insertHistoryData" type="primary"
                                       icon="el-icon-plus" size="mini">新增申请修改
                            </el-button>
                            <!-- 表格-->
                            <el-table :data="tableHistoryData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                                      stripe border class="user-table" height="500" style="width: 100%;"
                                      :header-cell-style="getRowClass">
                                <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                                <el-table-column prop="fileCode" label="文件编码" sortable width="140"></el-table-column>
                                <el-table-column prop="versionCode" label="版本号" sortable width="120"></el-table-column>
                                <el-table-column prop="applicantName" label="申请人" sortable
                                                 width="110"></el-table-column>
                                <el-table-column prop="applyTime" label="申请时间" :formatter="formatIsNull" sortable
                                                 width="170"></el-table-column>
                                <el-table-column prop="updateReason" label="申请原因" sortable
                                                 width="400"></el-table-column>
                                <el-table-column prop="approvalResult" label="申请结果" :formatter="formatIsResult" sortable
                                                 width="110"></el-table-column>
                                <el-table-column prop="isTrain" label="是否需要培训" :formatter="formatNeedTrain" sortable
                                                 width="200"></el-table-column>
                                <el-table-column fixed="right" label="操作" sortable align="right" width="170">
                                    <template slot-scope="scope">
                                        <el-button v-if="jurisdiction.addEditApplyInfo"
                                                   @click="updateHistoryData(scope.row)" type="text" size="small">编辑
                                        </el-button>
                                        <el-button @click="openExamine(scope.row)" type="text" size="small">审核
                                        </el-button>
                                        <el-button @click="openExamineHistory(scope.row)" type="text" size="small">
                                            历史记录
                                        </el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <!--分页-->
                            <el-pagination background @size-change="handleSizeChange"
                                           @current-change="handleCurrentChange" :current-page="currentPage"
                                           :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize"
                                           layout="total, sizes, prev, pager, next, jumper"
                                           :total="tableHistoryData.length"></el-pagination>
                        </el-tab-pane>
                        <el-tab-pane label="回收与发放记录" name="second">
                            <el-button v-if="jurisdiction.addPrintGrantInfo" @click="insertGrantRecoveryData"
                                       type="primary" icon="el-icon-plus" size="mini">新增发放
                            </el-button>
                            <el-table
                                    :data="tableGrantRecoveryData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                                    stripe border class="user-table" height="500" style="width: 100%;"
                                    :header-cell-style="getRowClass">
                                <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                                <el-table-column prop="versionCode" label="版本号" sortable width="170"></el-table-column>
                                <el-table-column prop="issuerName" label="发放人" sortable width="120"></el-table-column>
                                <el-table-column prop="num" label="发放数量" sortable width="120"></el-table-column>
                                <el-table-column prop="accepterName" label="接收人" sortable width="110"></el-table-column>
                                <el-table-column prop="acceptTime" label="接收时间" sortable width="170"></el-table-column>
                                <el-table-column prop="recyclingPersonName" label="回收人" sortable
                                                 width="110"></el-table-column>
                                <el-table-column prop="recyclingTime" label="回收时间" sortable
                                                 width="170"></el-table-column>
                                <el-table-column prop="recyclingVersionCode" label="回收号" sortable
                                                 width="170"></el-table-column>
                                <el-table-column prop="remark" label="备注" sortable width="350"></el-table-column>
                                <el-table-column fixed="right" label="操作" sortable align="right" width="80">
                                    <template slot-scope="scope">
                                        <el-button @click="updateGrantRecoveryData(scope.row)" type="text" size="small">
                                            回收
                                        </el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <el-pagination background @size-change="handleSizeChange"
                                           @current-change="handleCurrentChange" :current-page="currentPage"
                                           :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize"
                                           layout="total, sizes, prev, pager, next, jumper"
                                           :total="tableGrantRecoveryData.length"></el-pagination>
                        </el-tab-pane>
                        <el-tab-pane label="培训记录" name="third">
                            <el-table :data="tableTrainData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe
                                      border class="user-table" height="500" style="width: 100%;"
                                      :header-cell-style="getRowClass">
                                <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                                <el-table-column prop="versionCode" label="版本号" sortable width="180"></el-table-column>
                                <el-table-column prop="trainerName" label="培训主持人" sortable
                                                 width="130"></el-table-column>
                                <el-table-column prop="trainTime" label="培训时间" :formatter="formatTimestampToTime"
                                                 sortable width="170"></el-table-column>
                                <el-table-column prop="studyPersons" label="培训参与人" sortable
                                                 width="1100"></el-table-column>
                                <el-table-column fixed="right" label="操作" sortable align="right" width="80">
                                    <template slot-scope="scope">
                                        <el-button @click="updateTrainData(scope.row)" type="text" size="small">修改
                                        </el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <el-pagination background @size-change="handleSizeChange"
                                           @current-change="handleCurrentChange" :current-page="currentPage"
                                           :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize"
                                           layout="total, sizes, prev, pager, next, jumper"
                                           :total="tableTrainData.length"></el-pagination>
                        </el-tab-pane>
                        <el-tab-pane label="版本记录" name="four">
                            <el-table :data="tableEditionData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                                      stripe border class="user-table" height="500" style="width: 100%;"
                                      :header-cell-style="getRowClass">
                                <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                                <el-table-column prop="versionCode" label="版本号" sortable width="180"></el-table-column>
                                <el-table-column prop="fileCode" label="文件编码" sortable width="180"></el-table-column>
                                <el-table-column prop="issuer" label="发布人" sortable width="130"></el-table-column>
                                <el-table-column prop="issueTime" label="发布时间" sortable width="170"></el-table-column>
                                <el-table-column prop="versionDesc" label="版本描述" sortable width="800"></el-table-column>
                                <el-table-column fixed="right" label="操作" align="right" width="120">
                                    <template slot-scope="scope">
                                        <el-button @click="EditedVersionData(scope.row)" type="text" size="small">编辑
                                        </el-button>
                                        <el-button @click="updateEditionData(scope.row)" type="text" size="small">查看
                                        </el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <el-pagination background @size-change="handleSizeChange"
                                           @current-change="handleCurrentChange" :current-page="currentPage"
                                           :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize"
                                           layout="total, sizes, prev, pager, next, jumper"
                                           :total="tableEditionData.length"></el-pagination>
                        </el-tab-pane>
                    </el-tabs>
                </el-tab-pane>
                <el-tab-pane v-if="dialogTitle !=='添加'" label="目录" name="2" :style="tableDialogHeightTabPane">
                    <quill-editor v-model="dialogList2.fileContent"
                                  @focus="dialogList2.isLocked === 1 ? onEditorFocus($event) : ''"
                                  :style='tableDialogHeightQuill'></quill-editor>
                    <div v-if="jurisdiction.addBaseInfo" style="text-align: right;margin-top: 75px;padding-right: 2px;">
                        <el-button v-if="dialogList2.isLocked !== 1" @click="submitDialogDataOther(2)" type="primary">
                            提交
                        </el-button>
                    </div>
                </el-tab-pane>
            </el-tabs>


        <!-- 申请修改单记录弹框 -->
        <el-dialog :title="dialogHistoryTitle" width="600px" class="history-dialog" :visible.sync="isHistoryDialog"
                   :close-on-click-modal="false">
            <el-form label-position="right" label-width="110px" :model="dialogHistoryList">
                <el-form-item label="申请人">
                    <el-input v-model="dialogHistoryList.applicantName" disabled></el-input>
                </el-form-item>
                <el-form-item label="申请时间">
                    <el-input v-model="dialogHistoryList.applyTime" disabled></el-input>
                </el-form-item>
                <el-form-item label="文件编码">
                    <el-input v-model="dialogHistoryList.fileCode"
                              :disabled="dialogHistoryList.approvalResult === '1'"></el-input>
                </el-form-item>
                <el-form-item label="版本号">
                    <el-input v-model="dialogHistoryList.versionCode"
                              :disabled="dialogHistoryList.approvalResult === '1'"></el-input>
                </el-form-item>
                <el-form-item label="是否需要培训">
                    <el-select v-model="dialogHistoryList.isTrain" :disabled="dialogHistoryList.approvalResult === '1'">
                        <el-option label="否" value="0"></el-option>
                        <el-option label="是" value="1"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="申请原因">
                    <el-input v-model="dialogHistoryList.updateReason"
                              :disabled="dialogHistoryList.approvalResult === '1'" type="textarea"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button v-if="dialogHistoryList.approvalResult !== '1'" :disabled="!isDialogHistoryButton"
                           @click="submitHistoryDialogList" type="primary">确 定
                </el-button>
            </div>
        </el-dialog>

        <!-- 申请审核/历史记录弹框 -->
        <el-dialog :title="dialogExamineTitle" :width="dialogExamineWidth" top="60px" class="Examine-dialog"
                   :visible.sync="isExamineDialog" :close-on-click-modal="false">
            <!-- 申请审核表格-->
            <div v-if="dialogExamineTitle ==='审核列表' " style="padding-bottom: 20px;">
                <h3 class="dialog-plate-title" style="margin: 10px 0;"><span>审核部门列表</span></h3>
                <el-table :data="tableExamineData" stripe border height="300px" class="user-table" style="width: 100%;"
                          :header-cell-style="getRowClass">
                    <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                    <el-table-column prop="approvalerName" label="审核人" :formatter="formatIsNull" sortable
                                     width="110"></el-table-column>
                    <el-table-column prop="approvalTime" label="审核时间" :formatter="formatIsNull" sortable
                                     width="170"></el-table-column>
                    <el-table-column prop="deptName" label="审核部门" sortable width="160"></el-table-column>
                    <el-table-column prop="isApproval" label="审核结果" :formatter="formatIsResult" sortable
                                     width="110"></el-table-column>
                    <el-table-column prop="approvalAdvice" label="审核意见" :formatter="formatIsNull" sortable
                                     width="300"></el-table-column>
                    <el-table-column fixed="right" label="操作" sortable align="right" width="80">
                        <template slot-scope="scope">
                            <el-button @click="goExamine(scope.row)" type="text" size="small">审核</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <h3 v-if="isSubmitExamine" class="dialog-plate-title" style="margin: 20px 0 10px;"><span>审核操作</span>
                </h3>
                <div v-if="isSubmitExamine" style="padding-bottom: 20px;">
                    <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px"
                             :model="dialogExamineList">
                        <el-form-item label="审核人">
                            <el-input v-model="dialogExamineList.approvalerName" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="审核时间">
                            <el-input v-model="dialogExamineList.approvalTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="审核部门">
                            <el-input v-model="dialogExamineList.deptName" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="审核结果">
                            <el-select v-model="dialogExamineList.isApproval" :disabled="isGoExamineButton">
                                <el-option label="不通过" value="0"></el-option>
                                <el-option label="通过" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="110px" :model="dialogExamineList">
                        <el-form-item label="审核意见">
                            <el-input v-model="dialogExamineList.approvalAdvice" :disabled="isGoExamineButton"
                                      type="textarea" style="width: 523px;"></el-input>
                        </el-form-item>
                    </el-form>
                    <div v-if="jurisdiction.auditingApply" style="text-align: right;">
                        <el-button v-if="!isGoExamineButton" @click="submitExamine" type="primary">提交审核</el-button>
                    </div>
                </div>
            </div>
            <div v-else style="padding-bottom: 20px;">
                <el-table :data="tableExamineHistoryData" stripe border height="700px" class="user-table"
                          style="width: 100%;" :header-cell-style="getRowClass">
                    <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                    <el-table-column prop="fileUpdateWriterName" label="修改人" :formatter="formatIsNull" sortable
                                     width="110"></el-table-column>
                    <el-table-column prop="updateTime" label="修改时间" :formatter="formatIsNull" sortable
                                     width="170"></el-table-column>
                    <el-table-column prop="contentType" label="修改类型" :formatter="formatContentType" sortable
                                     width="110"></el-table-column>
                    <el-table-column prop="beforeContent" label="修改前" sortable width="600"></el-table-column>
                    <el-table-column prop="afterContent" label="修改后" sortable width="600"></el-table-column>
                </el-table>
            </div>
        </el-dialog>


        <!-- 发放与回收 -->
        <el-dialog :title="dialogGrantRecoveryTitle" width="700px" class="GrantRecovery-dialog"
                   :visible.sync="isGrantRecoveryDialog" :close-on-click-modal="false">
            <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px"
                     :model="dialogGrantRecoveryList">
                <el-form-item label="发放人">
                    <el-input v-model="dialogGrantRecoveryList.issuerName" disabled></el-input>
                </el-form-item>
                <el-form-item label="接收时间">
                    <el-input v-model="dialogGrantRecoveryList.acceptTime" disabled></el-input>
                </el-form-item>
                <el-form-item label="发放版本">
                    <el-input v-model="dialogGrantRecoveryList.issueCode" disabled></el-input>
                </el-form-item>
                <el-form-item label="发放数量">
                    <el-input type="number" v-model="dialogGrantRecoveryList.num"
                              :disabled="dialogGrantRecoveryTitle !== '发放'"></el-input>
                </el-form-item>
                <el-form-item label="接收人">
                    <el-select v-model="dialogGrantRecoveryList.accepterName"
                               :disabled="dialogGrantRecoveryTitle !== '发放'">
                        <el-option
                                v-for="item in userList"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <el-form v-if="dialogGrantRecoveryTitle !== '发放'" :inline="true" class="demo-form-inline"
                     label-position="right" label-width="110px" :model="dialogGrantRecoveryList">
                <el-form-item label="回收人">
                    <el-input v-model="dialogGrantRecoveryList.recyclingPersonName" disabled></el-input>
                </el-form-item>
                <el-form-item label="回收时间">
                    <el-input v-model="dialogGrantRecoveryList.recyclingTime" disabled></el-input>
                </el-form-item>
            </el-form>
            <el-form v-if="dialogGrantRecoveryTitle !== '发放'" :inline="true" class="demo-form-inline"
                     label-position="right" label-width="110px" :model="dialogGrantRecoveryList">
                <el-form-item label="回收版本">
                    <el-input v-model="dialogGrantRecoveryList.recyclingVersionCode"></el-input>
                </el-form-item>
            </el-form>
            <el-form label-position="right" label-width="110px" :model="dialogGrantRecoveryList">
                <el-form-item label="备注">
                    <el-input v-model="dialogGrantRecoveryList.remark" type="textarea" style="width: 522px;"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitGrantRecoveryDialogList"
                           :disabled="!isDialogGrantRecoveryButton">确 定
                </el-button>
            </div>
        </el-dialog>

        <!-- 培训 -->
        <el-dialog :title="dialogTrainTitle" width="600px" class="GrantRecovery-dialog" :visible.sync="isTrainDialog"
                   :close-on-click-modal="false">
            <el-form label-position="right" label-width="110px" :model="dialogTrainList">
                <el-form-item label="版本号">
                    <el-input v-model="dialogTrainList.versionCode" disabled></el-input>
                </el-form-item>
                <el-form-item label="培训主持人">
                    <el-input v-model="dialogTrainList.trainerName" disabled></el-input>
                </el-form-item>
                <el-form-item label="培训时间">
                    <el-date-picker v-model="dialogTrainList.trainTime" format="yyyy-MM-dd HH:mm:ss" type="datetime"
                                    placeholder="选择日期时间"></el-date-picker>
                </el-form-item>
                <el-form-item label="培训参与人员">
                    <el-input v-model="dialogTrainList.studyPersons" type="textarea"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="submitTrainDialogList" type="primary" :disabled="!isDialogTrainButton">确 定
                </el-button>
            </div>
        </el-dialog>


        <!-- 版本记录描述 -->
        <el-dialog title="编辑" width="600px" class="GrantRecovery-dialog" :visible.sync="isEditionDialog"
                   :close-on-click-modal="false">
            <el-form label-position="right" label-width="110px" :model="dialogEditionList">
                <el-form-item label="版本号">
                    <el-input v-model="dialogEditionList.versionCode" disabled></el-input>
                </el-form-item>
                <el-form-item label="文件编码">
                    <el-input v-model="dialogEditionList.fileCode" disabled></el-input>
                </el-form-item>
                <el-form-item label="发布人">
                    <el-input v-model="dialogEditionList.issuer" disabled></el-input>
                </el-form-item>
                <el-form-item label="发布时间">
                    <el-input v-model="dialogEditionList.issueTime" disabled></el-input>
                </el-form-item>
                <el-form-item label="版本描述">
                    <el-input v-model="dialogEditionList.versionDesc" type="textarea"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="submitVersionData" type="primary" :disabled="!isDialogEditionButton">确 定</el-button>
            </div>
        </el-dialog>

        <!-- 打印弹框 -->
        <el-dialog title="打印" class="print-dialog" width="1000px" top="30px" :visible.sync="isPrintDialog"
                   :close-on-click-modal="false">
            <el-button v-if="jurisdiction.addPrintGrantInfo" type="primary" @click="PrintData">打印文件</el-button>
            <div :model="dialogPrintList" id="printData" :style="tableDialogHeightPrint">
                <h2 style="text-align: center;">{{dialogPrintList.qsFile.fileName}}</h2>
                <ul class="printData_subTitle" style="overflow: hidden;margin: 10px 0 5px;">
                    <li style="list-style:none;float: left;font-size:12px;width: 10%;height: 20px;padding: 0 5px !important;text-align:right;">
                        文件编码：
                    </li>
                    <li style="list-style:none;float: left;font-size:12px;width: 20.6%;height: 20px;padding: 0 5px !important;">
                        {{dialogPrintList.qsFile.fileCode}}
                    </li>
                    <li style="list-style:none;float: left;font-size:12px;width: 10%;height: 20px;padding: 0 5px !important;text-align:right;">
                        {{ dialogPrintList.qsFile.fileId === "版本记录" ? "发布时间：" : "创建日期："}}
                    </li>
                    <li style="list-style:none;float: left;font-size:12px;width: 20.6%;height: 20px;padding: 0 5px !important;">
                        {{dialogPrintList.qsFile.createTime}}
                    </li>
                    <li style="list-style:none;float: left;font-size:12px;width: 10%;height: 20px;padding: 0 5px !important;text-align:right;">
                        版本号：
                    </li>
                    <li style="list-style:none;float: left;font-size:12px;width: 20.6%;height: 20px;padding: 0 5px !important;">
                        {{dialogPrintList.qsFile.versionCode}}
                    </li>
                </ul>
                <p style="font-size: 17px;margin: 0;">1、目录</p>
                <div style="margin: 10px 0 0; padding-left: 40px;font-size:12px;color: #666;"
                     v-html="dialogPrintList.qsFileContents[0].fileContent"></div>
            </div>
        </el-dialog>

    </div>
</template>

<script>

    import pdf from 'vue-pdf'
    import 'quill/dist/quill.core.css';
    import 'quill/dist/quill.snow.css';
    import 'quill/dist/quill.bubble.css';
    import {quillEditor} from 'vue-quill-editor';

    export default {
        name: "qualitySystem",
        components: {quillEditor, pdf},
        data() {
            let _token = sessionStorage.getItem("tokenId");
            let menuId = window.location.href.substr( window.location.href.lastIndexOf('/')+ 1 ) ;

            return {
                departments: [],
                userList: [],
                tokenId: _token,
                menuId: menuId,
                fileId: '',
                params: '',
                currentPage: 1,
                pagesize: 10,
                tableDialogHeightTabPane: {
                    height: (document.documentElement.clientHeight - 150) + 'px',
                    overflowY: 'auto',
                },
                tableDialogHeightQuill: {
                    height: (document.documentElement.clientHeight - 260) + 'px'
                },
                tableDialogHeightPrint: {
                    height: (document.documentElement.clientHeight - 200) + 'px',
                    overflowY: 'auto',
                    paddingBottom: "60px"
                },

                isDialogButton: true,
                activeName: '1',
                activeTableName: 'first',
                dialogTitle: '',
                quillContent: '',
                isFileUseScope: false,
                dialogList1: {
                    fileWriterName: "",
                    approvalTime: '',
                    createTime: "",
                    fileApprover: '',
                    fileCode: "",
                    fileGs: "",
                    fileId: '',
                    fileName: "",
                    fileUseScope: [],
                    fileWriter: "",
                    isApproval: "",
                    lastUpdateTime: "",
                    updateTimes: '',
                    versionCode: "",
                },
                dialogList2: {
                    contentType: '',
                    fileContent: '',
                    fileContentId: '',
                    fileContentWriter: '',
                    fileContentWriterName: '',
                    fileId: '',
                    isLocked: '',
                    isUse: '',
                },

                isHistory: true,
                isHistoryDialog: false,
                dialogHistoryTitle: '',
                isDialogHistoryButton: true,
                tableHistoryData: [],
                dialogHistoryList: {
                    id: '',
                    fileId: '',
                    applyTime: "",
                    applicant: "",
                    fileCode: '',
                    updateReason: "",
                    updateType: "",
                    approvalResult: "",
                    versionCode: "",
                    isFinishUpdate: "",
                    isTrain: "",
                    applicantName: ""
                },

                isExamine: true,
                isSubmitExamine: false,
                isExamineDialog: false,
                dialogExamineTitle: '',
                isDialogExamineButton: true,
                tableExamineData: [],
                dialogExamineWidth: '',
                isGoExamineButton: true,
                dialogExamineList: {
                    approvalAdvice: '',
                    approvalTime: '',
                    approvaler: '',
                    approvalerName: '',
                    deptId: "",
                    deptName: "",
                    fileId: '',
                    id: '',
                    isApproval: '',
                    updateId: '',
                },
                tableExamineHistoryData: [],

                isGrantRecoveryDialog: false,
                dialogGrantRecoveryTitle: '',
                isDialogGrantRecoveryButton: true,
                dialogGrantRecoveryList: {
                    acceptTime: '',
                    accepter: "",
                    accepterName: "",
                    fileId: '',
                    id: '',
                    issueCode: "",
                    issuer: "",
                    issuerName: "",
                    num: '',
                    recyclingPerson: '',
                    recyclingPersonName: '',
                    recyclingTime: '',
                    recyclingVersionCode: '',
                    remark: '',
                    versionCode: '',
                },
                tableGrantRecoveryData: [],


                isTrain: '',
                isTrainDialog: false,
                dialogTrainTitle: '',
                isDialogTrainButton: true,
                dialogTrainList: {
                    id: '',
                    fileId: '',
                    versionCode: '',
                    trainer: '',
                    trainerName: '',
                    studyPersons: '',
                    trainTime: '',
                },
                tableTrainData: [],


                isEditionDialog: false,
                isDialogEditionButton: true,
                dialogEditionList: {
                    fileCode: "",
                    fileId: "",
                    issueTime: "",
                    issuer: "",
                    qsFileContents: "",
                    versionCode: "",
                    versionDesc: "",
                },
                tableEditionData: [],


                isPrintDialog: false,
                dialogPrintList: {
                    qsFile: {
                        fileId: '',
                        fileName: '',
                        fileCode: "",
                        createTime: '',
                        lastUpdateTime: '',
                        versionCode: '',
                        updateTimes: '',
                        approvalTime: '',
                        fileApprover: "",
                        fileWriter: '',
                        fileGs: '',
                        isApproval: ''
                    },
                    qsFileContents: [
                        {
                            fileContentId: "",
                            fileId: "",
                            fileContent: "",
                            isLocked: "",
                            contentType: "2",
                            fileContentWriter: ""
                        },
                    ]
                },

                jurisdiction: {
                    addBaseInfo: true,
                    addEditApplyInfo: true,
                    addPrintGrantInfo: true,
                    auditingApply: true,
                    fileRelease: true,
                    selectList: true,
                },

            }
        },
        created() {
            this.getFileId();
            this.getDepartments();
            this.getUser();
        },
        methods: {
            getFileId(){
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/QsFile/selectZltxListTree/'+_this.menuId+'?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        let row = res.data.content;
                        _this.isDialogButton = true;
                        _this.dialogTitle = row.linkFileId ? row.listName : '添加';
                        _this.params = row.fileGs.substr(row.fileGs.lastIndexOf('/') + 1);
                        _this.fileId = row.linkFileId;
                        _this.activeName = '1';
                        _this.activeTableName = 'first';
                        _this.getJurisdiction();
                        if (_this.fileId) {
                            _this.getDialogData();
                            _this.getHistoryData();
                        } else {
                            _this.dialogList1 = {
                                fileWriterName: "",
                                approvalTime: '',
                                createTime: "",
                                fileApprover: '',
                                fileCode: "",
                                fileGs: _this.params,
                                fileId: '',
                                fileName: "",
                                fileUseScope: [],
                                fileWriter: "",
                                isApproval: "0",
                                lastUpdateTime: "",
                                updateTimes: '',
                                versionCode: "",
                            };
                            _this.isFileUseScope = false;
                        }
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getDepartments() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsQsfileDept/selectAllDept?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.departments = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getUser() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsIssueRecyclingQsfile/queryUser/' + _this.params + "?tokenId=" + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.userList = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("人员加载失败！请重新加载...");
                })
            },
            getJurisdiction() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/system/menu/getMenuAllSrc/33?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        for (let i = 0; i < res.data.content.length; i++) {
                            let item = res.data.content[i];
                            _this.jurisdiction[item.component] = item.menuShow;
                        }
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getDialogData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/QsFile/selectByFileId/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.dialogList1 = res.data.content;
                        _this.dialogList1.fileUseScope = _this.dialogList1.fileUseScope ? _this.dialogList1.fileUseScope : [];
                        _this.isFileUseScope = _this.dialogList1.fileUseScope.length === 0 ? false : true;

                        _this.isDialogButton = _this.dialogList1.isApproval !== '1' ? true : false;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getDialogTabPaneData(type) {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/QsFileContent/selectByFileId/' + _this.fileId + '/' + type + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this["dialogList" + type] = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getHistoryData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsApplyUpdateRecord/selectByFileId/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableHistoryData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getExamineData(id) {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsApprovalRecord/selectByUpdateId/' + id + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableExamineData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getExamineHistoryData(id) {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsUpdateHistoryRecord/selectByUpdateId/' + id + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableExamineHistoryData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getGrantRecoveryData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsIssueRecyclingQsfile/selectByFileId/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableGrantRecoveryData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getTrainData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsUpdatedFileTrain/selectByFileId/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableTrainData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getEditionData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/QsFile/historyVersion/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableEditionData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },


            handleDialogClick(tab, event) {
                if (tab.name !== '1') {
                    this.getDialogTabPaneData(tab.name);
                }
            },
            handleRecordClick(tab, event) {
                if (tab.name === 'first') {
                    this.getHistoryData();
                } else if (tab.name === 'second') {
                    this.getGrantRecoveryData();
                } else if (tab.name === 'third') {
                    this.getTrainData();
                } else if (tab.name === 'four') {
                    this.getEditionData();
                }
            },
            submitDialogData1() {
                let _this = this;
                _this.isDialogButton = false;
                let url;
                if (this.dialogTitle === '添加') {
                    url = '/api/adscm/zltx/QsFile/insert?treeId=' + _this.menuId + '&tokenId=' + _this.tokenId;
                } else {
                    url = '/api/adscm/zltx/QsFile/update?treeId=' + _this.menuId + '&tokenId=' + _this.tokenId;
                }
                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogList1
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.getData();
                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogButton = true;
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogButton = true;
                })
            },
            submitDialogDataOther(type) {
                let _this = this;
                let param = _this["dialogList" + type];
                param.contentType = type;
                param.fileId = _this.fileId;
                this.$http({
                    url: '/api/adscm/zltx/QsFileContent/update?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: param
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.$message.success(res.data.desc);
                        _this.getDialogTabPaneData(type);
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },

            insertHistoryData() {
                let _this = this;
                _this.isHistoryDialog = true;
                _this.isDialogHistoryButton = true;
                _this.dialogHistoryTitle = '添加';
                _this.dialogHistoryList = {
                    id: '',
                    fileId: _this.fileId,
                    applyTime: "",
                    fileCode: '',
                    applicant: "",
                    updateReason: "",
                    updateType: "",
                    approvalResult: "",
                    versionCode: "",
                    isFinishUpdate: "",
                    isTrain: "1",
                    applicantName: ""
                }
            },
            updateHistoryData(row) {
                let _this = this;
                _this.isHistoryDialog = true;
                _this.isDialogHistoryButton = true;
                _this.dialogHistoryTitle = '编辑';
                _this.dialogHistoryList = {
                    id: row.id,
                    fileId: row.fileId,
                    applyTime: row.applyTime,
                    fileCode: row.fileCode,
                    applicant: row.applicant,
                    updateReason: row.updateReason,
                    updateType: row.updateType,
                    approvalResult: row.approvalResult,
                    versionCode: row.versionCode,
                    isFinishUpdate: row.isFinishUpdate,
                    isTrain: row.isTrain,
                    applicantName: row.applicantName
                }
            },
            submitHistoryDialogList() {
                let _this = this;
                _this.isDialogHistoryButton = false;
                let url;

                if (_this.dialogHistoryTitle === '添加') {
                    url = '/api/adscm/zltx/qsApplyUpdateRecord/insert?tokenId=' + _this.tokenId;
                } else if (_this.dialogHistoryTitle === '编辑') {
                    url = '/api/adscm/zltx/qsApplyUpdateRecord/update?tokenId=' + _this.tokenId;
                }
                this.$http({
                    url: url,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    data: _this.dialogHistoryList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isHistoryDialog = false;
                        _this.getHistoryData();
                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogHistoryButton = true;
                    }
                }).catch(function (error) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogHistoryButton = true;
                })
            },
            openExamine(row) {
                this.isExamineDialog = true;
                this.isSubmitExamine = false;
                this.dialogExamineTitle = '审核列表';
                this.dialogExamineWidth = '900px';
                this.getExamineData(row.id);
            },
            goExamine(row) {
                this.isSubmitExamine = true;
                this.dialogExamineList = {
                    approvalAdvice: row.approvalAdvice,
                    approvalTime: row.approvalTime,
                    approvaler: row.approvaler,
                    approvalerName: row.approvalerName,
                    deptId: row.deptId,
                    deptName: row.deptName,
                    fileId: row.fileId,
                    id: row.id,
                    isApproval: row.isApproval,
                    updateId: row.updateId,
                };
                this.isGoExamineButton = row.isApproval !== '1' ? false : true;

            },
            submitExamine() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsApprovalRecord/update?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    data: _this.dialogExamineList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.getExamineData(_this.dialogExamineList.updateId);
                        _this.getHistoryData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (error) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            openExamineHistory(row) {
                this.isExamineDialog = true;
                this.dialogExamineTitle = '申请历史列表';
                this.dialogExamineWidth = '85%';
                this.getExamineHistoryData(row.id);
            },

            insertGrantRecoveryData() {
                let _this = this;
                _this.isGrantRecoveryDialog = true;
                _this.dialogGrantRecoveryTitle = '发放';
                _this.isDialogGrantRecoveryButton = true;
                _this.dialogGrantRecoveryList = {
                    acceptTime: '',
                    accepter: "",
                    accepterName: "",
                    fileId: _this.fileId,
                    id: '',
                    issueCode: "",
                    issuer: "",
                    issuerName: "",
                    num: '',
                    recyclingPerson: '',
                    recyclingPersonName: '',
                    recyclingTime: '',
                    recyclingVersionCode: '',
                    remark: '',
                    versionCode: '',
                }
            },
            updateGrantRecoveryData(row) {
                let _this = this;
                _this.isGrantRecoveryDialog = true;
                _this.dialogGrantRecoveryTitle = '回收';
                _this.isDialogGrantRecoveryButton = true;

                _this.dialogGrantRecoveryList = {
                    acceptTime: row.acceptTime,
                    accepter: row.accepter,
                    accepterName: row.accepterName,
                    fileId: row.fileId,
                    id: row.id,
                    issueCode: row.issueCode,
                    issuer: row.issuer,
                    issuerName: row.issuerName,
                    num: row.num,
                    recyclingPerson: row.recyclingPerson,
                    recyclingPersonName: row.recyclingPersonName,
                    recyclingTime: row.recyclingTime,
                    recyclingVersionCode: row.recyclingVersionCode,
                    remark: row.remark,
                    versionCode: row.versionCode
                }
            },
            submitGrantRecoveryDialogList() {
                let _this = this;
                let url;
                _this.isDialogGrantRecoveryButton = false;
                if (_this.dialogGrantRecoveryTitle === '发放') {
                    url = '/api/adscm/zltx/qsIssueRecyclingQsfile/insert?tokenId=' + _this.tokenId;
                } else if (_this.dialogGrantRecoveryTitle === '回收') {
                    url = '/api/adscm/zltx/qsIssueRecyclingQsfile/update?tokenId=' + _this.tokenId;
                }
                this.$http({
                    url: url,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    data: _this.dialogGrantRecoveryList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isGrantRecoveryDialog = false;
                        _this.getGrantRecoveryData(_this.dialogGrantRecoveryList.fileId);
                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogGrantRecoveryButton = true;
                    }
                }).catch(function (error) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogGrantRecoveryButton = true;
                })


            },

            updateTrainData(row) {
                let _this = this;
                _this.isTrainDialog = true;
                _this.dialogTrainTitle = '编辑';
                _this.isDialogTrainButton = true;
                _this.dialogTrainList = {
                    id: row.id,
                    fileId: row.fileId,
                    versionCode: row.versionCode,
                    trainer: row.trainer,
                    trainerName: row.trainerName,
                    studyPersons: row.studyPersons,
                    trainTime: row.trainTime ? this.timestampToTime(row.trainTime) : '',
                }
            },
            submitTrainDialogList() {
                let _this = this;
                _this.isDialogTrainButton = false;
                this.$http({
                    url: '/api/adscm/zltx/qsUpdatedFileTrain/update?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    data: _this.dialogTrainList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isTrainDialog = false;
                        _this.getTrainData();
                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogTrainButton = true;
                    }
                }).catch(function (error) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogTrainButton = true;
                })
            },

            updateEditionData(row) {
                this.isPrintDialog = true;
                this.dialogPrintList = {
                    qsFile: {
                        fileId: '版本记录',
                        fileName: this.dialogList1.fileName,
                        fileCode: row.fileCode,
                        createTime: row.issueTime,
                        lastUpdateTime: '',
                        versionCode: row.versionCode,
                        updateTimes: '',
                        approvalTime: '',
                        fileApprover: "",
                        fileWriter: '',
                        fileGs: '',
                        isApproval: ''
                    },
                    qsFileContents: row.qsFileContents
                };

            },

            EditedVersionData(row) {
                this.isEditionDialog = true;
                this.dialogEditionList = {
                    fileCode: row.fileCode,
                    fileId: row.fileId,
                    issueTime: row.issueTime ? row.issueTime : '',
                    issuer: row.issuer ? row.issuer : '',
                    qsFileContents: row.qsFileContents,
                    versionCode: row.versionCode,
                    versionDesc: row.versionDesc,
                };
            },
            submitVersionData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/QsFile/updateHistoryVersion?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    data: _this.dialogEditionList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isEditionDialog = false;
                        _this.getEditionData();
                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogEditionButton = true;
                    }
                }).catch(function (error) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogEditionButton = true;
                })
            },


            openPrintData() {
                let _this = this;
                if (_this.dialogTitle !== '添加') {
                    this.$http({
                        url: '/api/adscm/zltx/QsFile/printCurrentVersion/' + _this.fileId + '?tokenId=' + _this.tokenId,
                        method: 'post',
                        headers: {'X-Requested-With': 'XMLHttpRequest'},
                    }).then(function (res) {
                        if (res.data.statusCode == 200) {
                            _this.isPrintDialog = true;
                            _this.dialogPrintList = res.data.content;
                        } else {
                            _this.$message.error(res.data.desc);
                        }
                    }).catch(function (catchres) {
                        _this.$message.error("加载失败！请重新加载...");
                    })
                } else {
                    _this.$message({message: '还没有录入信息，不能查看！', type: 'warning'});
                }
            },
            PrintData() {
                let printHtml = document.getElementById("printData").innerHTML;
                let wind = window.open("", 'newwindow', 'height=2000, width=2000, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no');
                wind.document.body.innerHTML = printHtml;
                wind.print();
                wind.window.document.body.innerHTML = '';
            },


            formatContentType(row, column, cellValue, index) {
                return cellValue ? (cellValue === "2" ? '目录' : (cellValue === "3" ? '适用范围' : (cellValue === "4" ? '职责' : (cellValue === "5" ? '定义/缩写语' : (cellValue === "6" ? '流程图' : (cellValue === "7" ? '程序' : (cellValue === "8" ? '相关文件' : (cellValue === "9" ? '相关记录' : (cellValue === "10" ? '附件' : ''))))))))) : '';
            },
            formatIsResult(row, column, cellValue, index) {
                return cellValue ? (cellValue == 0 ? '不通过' : (cellValue == 1 ? '通过' : (cellValue == -1 ? '待审核' : ''))) : '';
            },
            FormatterTableUpdateType(row, column, cellValue, index) {
                return cellValue == 1 ? '修订' : '新增';
            },
            handleSizeChange(size) {
                this.pagesize = size;
            },
            handleCurrentChange  (currentPage) {
                this.currentPage = currentPage;
            },

        }

    }
</script>

<style scoped>
    @import "qualitySystem.css";
</style>
